<?php
namespace app\admin\controller;
use app\common\controller\Common;
use think\Request;
class Admin extends Common
{
	public function _initialize(){
		parent::_initialize();
		$this->model = model('Admin');
	}

	/**
	 * 修改密码/系统安全
	 */
	public function update_pwd()
	{
		$row = $this->model->get(session('admin.admin_id'));
		if(Request()->isGet()){
			return $this->fetch('');
		}
		if(Request()->isPost()){
			$data = input('post.');
			$row->password = get_pwd($data['query_pwd'],config('overall.PWD_STR'));
			$result = $row->validate('Admin.add')->allowField(true)->save($data);
			if( $result === false ){
				$this->error($row->getError());
			}
			$this->success(config('status.SUCCESS_ONE'));
		}
	}
}